package com.atguigu.gulimail.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyRedisssonConfig {

    /**
     * 所有对redission的使用都要通过RedissonClient对象
     * @return
     * @throws Exception
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() throws Exception{
        Config config = new Config();
        config.useSingleServer()
              .setAddress("redis://172.20.10.10:6379");

        // 2、 根据config创建出redissionClient实例
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }
}
